package com.zed.api.domain.currentuser;

/**
 * 当前用户提供者封装器
 * <p>
 * 可拦截获取当前用户的信息
 *
 * @author Zed
 */
public abstract class CurrentUserProviderWrapper implements CurrentUserProvider {

    private final CurrentUserProvider previous;

    /**
     *
     */
    public CurrentUserProviderWrapper(CurrentUserProvider previous) {
        this.previous = previous;
    }

    @Override
    public CurrentUser getCurrentUser() {
        return this.previous == null ? null : this.previous.getCurrentUser();
    }

    /**
     * 前一个当前用户提供者
     *
     * @return {@link CurrentUserProvider},可能为null.
     */
    protected CurrentUserProvider getPrevious() {
        return this.previous;
    }
}
